/*******************************************************************************
 * Copyright (c) 2011 Olexandr V. Shaposhnikov.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Olexandr V. Shaposhnikov - initial API and implementation and/or initial documentation
 *******************************************************************************/
package com.funkyroach.use.core.ast.expr;

import org.eclipse.dltk.ast.ASTVisitor;
import org.eclipse.dltk.ast.expressions.Expression;

public class USTernaryExpression extends USExpression {

	private Expression logicalExpression;
	private Expression trueExpression;
	private Expression falseExpression;

	public USTernaryExpression(Expression logicalExpression,
			Expression trueExpression, Expression falseExpression) {
		super();
		this.logicalExpression = logicalExpression;
		this.trueExpression = trueExpression;
		this.falseExpression = falseExpression;
	}

	public Expression getLogicalExpression() {
		return logicalExpression;
	}

	public void setLogicalExpression(Expression logicalExpression) {
		this.logicalExpression = logicalExpression;
	}

	public Expression getTrueExpression() {
		return trueExpression;
	}

	public void setTrueExpression(Expression trueExpression) {
		this.trueExpression = trueExpression;
	}

	public Expression getFalseExpression() {
		return falseExpression;
	}

	public void setFalseExpression(Expression falseExpression) {
		this.falseExpression = falseExpression;
	}

	public void traverse(ASTVisitor visitor) throws Exception {
		if (visitor.visit(this)) {
			if (logicalExpression != null) {
				logicalExpression.traverse(visitor);
			}
			if (trueExpression != null) {
				trueExpression.traverse(visitor);
			}
			if (falseExpression != null) {
				falseExpression.traverse(visitor);
			}
			visitor.endvisit(this);
		}
	}

}
